#include <algorithm>
#include <cstdint>
#include <iostream>
#include <istream>
using ll = int32_t;

const ll maxn = 1005;
ll n,ans,ans1,a[maxn][maxn];

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);

    std::cin>>n;
    for(ll i=1;i<=n;i++){
        ll n1=0,n2=0;
        for(ll j=1;j<=n;j++){
            std::cin>>a[i][j];
            if(j&1)n1+=a[i][j];
            else n2+=a[i][j];
        }
        ans+=std::max(n1,n2);
    }

    for(ll j=1;j<=n;j++){
        ll n1=0,n2=0;
        for(ll i=1;i<=n;i++){
            if(i&1)n1+=a[i][j];
            else n2+=a[i][j];
        }
        ans1+=std::max(n1,n2);
    }
    std::cout<<std::max(ans1,ans)<<"\n";
}